from django.db import models
from django.contrib.auth.models import User
from user_center.const import DefaultHeadUrl


# Create your models here.
class Video(models.Model):
    title = models.CharField(max_length=256)
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
    video_url = models.CharField(max_length=1024)
    cover_url = models.CharField(max_length=1024, default="")
    mask = models.BooleanField(default=False)

    def to_vo(self):
        return {
            "id": self.id,
            "title": self.title,
            "user": {
                "id": self.user.id,
                "username": self.user.username,
                "head_url": DefaultHeadUrl,
            },
            "cover_url": self.cover_url
        }
